package com.haixiaoke.saas.repository.service.impl;

import com.haixiaoke.saas.repository.mapper.BannerMapper;
import com.haixiaoke.saas.repository.pojo.Banner;
import com.haixiaoke.saas.repository.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 轮播Service业务层处理
 *
 * @author zhiping
 * @date 2023-06-02
 */
@Service
public class BannerServiceImpl implements IBannerService {

    @Autowired
    private BannerMapper bannerMapper;

    /**
     * 查询轮播
     *
     * @param id 轮播主键
     * @return 轮播
     */
    @Override
    public Banner selectBannerById(Long id) {
        return bannerMapper.selectBannerById(id);
    }

    /**
     * 查询轮播列表
     *
     * @param banner 轮播
     * @return 轮播
     */
    @Override
    public List<Banner> selectBannerList(Banner banner) {
        return bannerMapper.selectBannerList(banner);
    }

    /**
     * 新增轮播
     *
     * @param banner 轮播
     * @return 结果
     */
    @Override
    public int insertBanner(Banner banner) {
        banner.setCreateTime(new Date());
        return bannerMapper.insertBanner(banner);
    }

    /**
     * 修改轮播
     *
     * @param banner 轮播
     * @return 结果
     */
    @Override
    public int updateBanner(Banner banner) {
        banner.setUpdateTime(new Date());
        return bannerMapper.updateBanner(banner);
    }

    /**
     * 批量删除轮播
     *
     * @param ids 需要删除的轮播主键
     * @return 结果
     */
    @Override
    public int deleteBannerByIds(Long[] ids) {
        return bannerMapper.deleteBannerByIds(ids);
    }

    /**
     * 删除轮播信息
     *
     * @param id 轮播主键
     * @return 结果
     */
    @Override
    public int deleteBannerById(Long id) {
        return bannerMapper.deleteBannerById(id);
    }
}
